#include <bits/stdc++.h>
using namespace std;

#ifdef LOCAL
#define DEBUG(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define DEBUG(...) 42
#endif

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

int main() {
    // 本地调试时重定向输入输出
    #ifdef LOCAL
        const string input_file = "data.in";
        const string output_file = "data.out";
        
        if (freopen(input_file.c_str(), "r", stdin) == nullptr) {
            cerr << "Failed to open input file: " << input_file << endl;
            return 1;
        }
        if (freopen(output_file.c_str(), "w", stdout) == nullptr) {
            cerr << "Failed to open output file: " << output_file << endl;
            return 1;
        }
        
        auto start_time = chrono::high_resolution_clock::now();
    #endif
    
    // ================ 你的代码从这里开始 ================
    int n;
    cin >> n;
    vector<int> arr(n);
    for (int i = 0; i < n; i++) {
        arr[i]=i;
    }
    DEBUG(arr[0], arr[n - 1]); // 调试输出第一个和最后一个元素
    // 示例：计算数组和
    long long sum = accumulate(arr.begin(), arr.end(), 0LL);
    cout << sum << endl;
    
    // ================ 你的代码到这里结束 ================
    
    #ifdef LOCAL
        auto end_time = chrono::high_resolution_clock::now();
        auto duration = chrono::duration_cast<chrono::milliseconds>(end_time - start_time);
        cerr << "Time cost: " << duration.count() << " ms" << endl;
        
        // 关闭文件流
        fclose(stdin);
        fclose(stdout);
        
        // 恢复标准输入输出（可选）
        freopen("CON", "r", stdin);
        freopen("CON", "w", stdout);
    #endif
    
    return 0;
}